package com.guos.bio;

import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 每一行代码，都是改变世界的力量
 *
 * @author 郭帅
 * @date 2022/6/22 3:07 下午
 */
public class Client {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 8080);

        OutputStream outputStream = socket.getOutputStream();
        // 从控制台读取输入，并写入到 outputStream 中
        Scanner sc = new Scanner(System.in);
        while (true) {
            String input = sc.nextLine();
            if ("exit".equals(input)) {
                break;
            }
            outputStream.write(input.getBytes(StandardCharsets.UTF_8));
        }
        socket.close();
    }
}
